package com.shiro.dao;

import com.shiro.entity.Token;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;


@Repository("tokenSimpleDao")
public class TokenSimpleDaoImpl implements TokenSimpleDao{

	@Autowired
	private MongoTemplate mongoTemplate;

	@Override
	public Token findByToken(String token) {
		Query query = new Query();
        query.addCriteria( Criteria.where("token").is(token) );
		return mongoTemplate.findOne(query,Token.class);
	}
	
}